package com.tanger.auth.event;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @Description 用户事件监听
 * @Author Hchenbin
 * @Date 2022/7/20 17:35
 * @Version 1.0
 */
@Component
public class UserEventListener {

    Logger LOGGER = LoggerFactory.getLogger(UserEventListener.class);

    /**
     * @Description @Async 异步操作 eventTraceExecutor 自定义线程池，提高线程利用率，执行效率
     * 事件可作为日志记录
     * @param event
     */
    @Async("eventTraceExecutor")
    @EventListener
    public void userEventListener(LoginEvent event){
        LOGGER.info("监听用户事件:" + "发布事件类型{" + event.getEventType() +"}" + "发布事件名称{" + event.getEventName() + "}" + "发布事件资源{"+event.getSource().toString()+"}");
    }
}
